﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartWMS.Common.Extensions;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.Base;
using SmartWMS.Domain.BasicsDatum;
using SmartWMS.Server.BasicsDatumServer.CategoryService.Dto;
using SmartWMS.Server.BasicsDatumServer.ProductService;
using Yitter.IdGenerator;

namespace SmartWMS.API.Controllers.BasicsDatumMange
{
    /// <summary>
    /// 产品类别控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "BasicsDatum")]

    public class CategoryController : ControllerBase
    {
        private readonly ICategoryService _categoryService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="categoryService"></param>
        public CategoryController(ICategoryService categoryService)
        {
            _categoryService = categoryService;
        }

        /// <summary>
        /// 产品类别列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public  Task<Response<List<CategoryInput>>> CategoryListAsync(Select input)
        {
            var list = _categoryService.CategoryListAsync(input);
            return list;
        }

        /// <summary>
        /// 绑定下拉
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public  Task<Response<List<CategoryInput>>> CategoryListBind()
        {
            var list =  _categoryService.CategoryList();
            return list;
        }

        /// <summary>
        /// 产品类别添加
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<bool>> AddCategory(CategoryInput input)
        {
            input.CreateTime=DateTime.Now;
            var resault = _categoryService.AddCategory(input);

            return resault;
        }

        /// <summary>
        /// 产品类别删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<bool>> DeleteCategory(CategoryInput input)
        {
            var resault = _categoryService.DeleteCategory(input);
            return resault;
        }

        /// <summary>
        /// 产品类别反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<Category>> GetCategoryById(KeyEntity id)
        {
            var resault = _categoryService.GetCategoryById(id);
            return resault;
        }

        /// <summary>
        /// 产品类别修改
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<bool>> UpdateCategory(CategoryInput dto)
        {
            var result = _categoryService.UpdateCategory(dto);
            return result;
        }

        /// <summary>
        /// 产品类别批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<Response<bool>> DeleteCategoryList(CategoryInput dto)
        {
            var result = _categoryService.DeleteCategoryList(dto);
            return result;
        }

    }
}
